<?php 
    $key = $_POST['key_search'];
    $tmp = new XTemplate('sites/views/hocsinh/list.html');
    $sql = "SELECT monhoc . * , hocsinh . *,hocsinh_monhoc.*
            FROM `monhoc`
            LEFT JOIN hocsinh_monhoc ON monhoc.id = hocsinh_monhoc.id_mon
            LEFT JOIN hocsinh ON hocsinh.id = hocsinh_monhoc.id_hs 
            WHERE monhoc.tenmonhoc LIKE '%$key%' OR hocsinh_monhoc.diemtp_15ph LIKE '%$key%' 
            OR hocsinh_monhoc.diemtp_1t LIKE '%$key%' OR hocsinh_monhoc.diemtp_hk LIKE '%$key%' 
            OR hocsinh_monhoc.diem_tbm LIKE '%$key%' OR hocsinh.fullname LIKE '%$key%'";
     $arr = $db->GetArray($sql);
     foreach($arr as $value){
    	 $tmp->insert_loop('MON.HOCSINH', array('HOCSINH'=>$value));
     }
     //print_r($arr);
     $tmp->parse('MON');
     $maincontent = $tmp->text('MON');
?>